'use strict';
var city = [
    ["东城区", "西城区", "朝阳区", "丰台区", "石景山区", "海淀区", "顺义区", "通州区", "大兴区", "房山区", "门头沟区", "昌平区", "平谷区", "密云区", "怀柔区", "延庆区"],
    ["越秀区", "荔湾区", "海珠区", "天河区", "白云区", "黄埔区", "番禺区", "花都区", "南沙区", "增城区", "从化区"],
    ["黄浦区", "徐汇区", "长宁区", "静安区", "普陀区", "虹口区", "杨浦区", "浦东新区", "闵行区", "宝山区", "嘉定区", "金山区", "松江区", "青浦区", "奉贤区", "崇明区"],
    ["福田区", "罗湖区", "南山区", "盐田区", "宝安区", "龙岗区", "坪山区", "龙华区", "光明新区", "大鹏新区"],
];
var bus = new Vue();
var g_upload_column = '';
const upload1 = {
    template: `<div class="container-fluid">
        <div class="demo" width="80%">
            <ol class="progtrckr" data-progtrckr-steps="5">
                <li class="progtrckr-done">Step 1</li>
                <li class="progtrckr-todo">Step 2</li>
                <li class="progtrckr-todo">Step 3</li>
                <li class="progtrckr-todo">Step 4</li>
                <li class="progtrckr-todo">Step 5</li>
            </ol>
        </div>
        <br>
        <br>
        <div class="modal-body" style="padding-left: 50px">

            <div class="center" style="font-size: medium">
                <h3 class="modal-title" id="myModalLabel">
                    请填写房屋的基本信息
                </h3>
                </br>
                <div style="padding-left: 50px">
                    <div>
                        <label>
                            请选择您的出租类型 &emsp;
                            <select style="font-weight: normal" id="rent-type" name="rent-type" v-model="rentType">
                            <option selected="" value="0" disabled="">请选择</option>
                            <option value="合租">合租</option>
                            <option value="整租">整租</option>
                            </select>
                        </label>
                    </div>

                    <div style="padding-left:15px;padding-top: 5px">
                        <label> 请选择房屋的户型 &emsp;
                            <select style="font-weight: normal" id="rent-type1" name="rent-type" v-model="styleRoom">
                                <option selected="" value="0" disabled="">请选择</option>
                                <option value="1">1</option>
                                <option value="2">2</option>
                                <option value="3">3</option>
                                <option value="4">4</option>
                                <option value="5">5</option>
                            </select>
                            室
                            <select style="font-weight: normal" id="rent-type2" name="rent-type" v-model="styleHall">
                                <option selected="" value="0" disabled="">请选择</option>
                                <option value="1">1</option>
                                <option value="2">2</option>
                                <option value="3">3</option>
                                <option value="4">4</option>
                                <option value="5">5</option>
                            </select>
                            厅
                        </label>
                    </div>

                    <div style="padding-left:111px;padding-top: 5px">
                        <label> 朝向 &emsp;
                            <input type="text" style="width:75px;font-weight: normal" v-model="orientation">
                        </label>
                    </div>

                    <div style="padding-left:111px;padding-top: 5px">
                        <label> 面积 &emsp;
                            <input type="text" style="width:75px;font-weight: normal" v-model="area"> ㎡
                        </label>
                    </div>

                    <div style="padding-left:111px;padding-top: 5px">
                        <label>楼层 &emsp;
                            <input type="text" style="width:75px;font-weight: normal" v-model="floor"> 层
                        </label>
                    </div>


                    <div style="padding-left:96px;padding-top: 5px">
                        <label>所在地 &emsp;
                            <FORM METHOD=POST ACTION="" name="form1" style="margin:0px;display:inline;">
                                <select NAME="province" onChange="getCity()" style="font-weight: normal" v-model="regionCity">
                                    <option selected="" value="0" disabled="">请选择城市</option>
                                    <OPTION VALUE="北京">北京</OPTION>
                                    <OPTION VALUE="广州">广州</OPTION>
                                    <OPTION VALUE="上海">上海</OPTION>
                                    <OPTION VALUE="深圳">深圳</OPTION>
                                </select>
                                <SELECT NAME="city" style="font-weight: normal" v-model="regionArea" v-on:change="changeArea">
                                    <option selected="" value="0" disabled="">请选择行政区</option>
                                </SELECT>
                            </FORM>
                        </label>
                    </div>

                    <div style="padding-left:84px;padding-top: 5px">
                        <label> 小区名称&emsp;
                            <input type="text" style="width:350px;font-weight: normal" v-model="village">
                        </label>
                    </div>

                    <div style="padding-left:84px;padding-top: 5px">
                        <label> 详细地址&emsp;
                            <input type="text" style="width:350px;font-weight: normal" v-model="address">
                        </label>
                    </div>


                    <div style="padding-left:84px;padding-top: 5px">
                        <label> 周边设施&emsp;
                            <input type="text" style="width:350px;font-weight: normal" v-model="facility">
                        </label>
                    </div>


                    <div style="padding-left:84px;padding-top: 5px">
                        <label> 交通出行&emsp;
                            <input type="text" style="width:350px;font-weight: normal" v-model="traffic">
                        </label>
                    </div>

                    <br>
                    <div style="padding-left: 500px">
                        <a v-on:click="showUpload2">
                            <button type="button" class="btn btn-primary">
                                下一步
                            </button>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>`,
    data() {
        return {
            rentType: "0",
            styleRoom: '0',
            styleHall: '0',
            orientation: '',
            area: "0",
            floor: '',
            regionCity: "0",
            regionArea: "0",
            village: '',
            address: '',
            facility: '',
            traffic: '',
            region: '',
        }
    },
    methods: {
        changeArea() {
            var sltProvince = document.form1.province;
            //获得城市下拉框的对象
            var sltCity = document.form1.city;
            //得到对应省份的城市数组
            var provinceCity = city[sltProvince.selectedIndex - 1];
            this.region = this.regionCity + ' ' + provinceCity[sltCity.selectedIndex - 1];
        },
        showUpload2() {
            this.$emit('submit', {
                rentType: this.rentType,
                style: this.styleRoom + '室' + this.styleHall + '厅',
                orientation: this.orientation,
                area: this.area,
                floor: this.floor,
                region: this.region,
                village: this.village,
                address: this.address,
                facility: this.facility,
                traffic: this.traffic,
            });
            this.$emit('show', 2);
        }
    }
};
const upload2 = {
    template: `<div class="container-fluid">
        <div class="demo" width="80%">
            <ol class="progtrckr" data-progtrckr-steps="5">
                <li class="progtrckr-done">Step 1</li>
                <li class="progtrckr-done">Step 2</li>
                <li class="progtrckr-todo">Step 3</li>
                <li class="progtrckr-todo">Step 4</li>
                <li class="progtrckr-todo">Step 5</li>
            </ol>
        </div>
        <br>
        <br>

        <div class="modal-body" style="padding-left: 50px">

            <div class="center" style="font-size: medium">

                <h3 class="modal-title" id="myModalLabel">
                    请上传各房间的实拍图片
                </h3>

                <br>

                <div style="padding-left: 50px">

                    <div>
                        <label style="font-weight: normal">卧室</label>
                        <div style="padding-left: 46px;" id="container">
                            <label>请上传该房间的实拍图片</label>
                             <button class="btn" data-toggle="modal" data-target="#upload" v-on:click="changeColumn('卧室')">
                            上传图片
                            </button>
                        </div>
                    </div>
                    <br>

                    <div>
                        <label style="font-weight: normal">洗手间</label>
                        <div style="padding-left: 46px;">
                            <label>请上传该房间的实拍图片</label>
                            <button class="btn" data-toggle="modal" data-target="#upload" v-on:click="changeColumn('洗手间')">
                            上传图片
                            </button>
                        </div>
                    </div>
                    <br>

                    <div>
                        <label style="font-weight: normal">厨房</label>
                        <div style="padding-left: 46px;">
                            <label>请上传该房间的实拍图片</label>
                            <button class="btn" data-toggle="modal" data-target="#upload" v-on:click="changeColumn('厨房')">
                            上传图片
                            </button>
                        </div>
                    </div>
                    <br>
                    <div>
                        <label style="font-weight: normal">客厅</label>
                        <div style="padding-left: 46px;">
                            <label>请上传该房间的实拍图片</label>
                            <button class="btn" data-toggle="modal" data-target="#upload" v-on:click="changeColumn('客厅')">
                            上传图片
                            </button>
                        </div>
                    </div>
                    <br>
                    <div>
                        <label style="font-weight: normal">户型图</label>
                        <div style="padding-left: 46px;">
                            <label>请上传户型图</label>
                            <button class="btn" data-toggle="modal" data-target="#upload" v-on:click="changeColumn('户型图')">
                            上传图片
                            </button>
                        </div>
                    </div>
                    <br>
                    <div>
                        <label style="font-weight: normal"><input id="if12" type="checkbox" v-on:click="clickif12">阳台</label>
                        <div class="zl12" style=" display: none;padding-left: 46px;">
                            <label>请上传该房间的实拍图片：</label>
                            <button class="btn" data-toggle="modal" data-target="#upload" v-on:click="changeColumn('阳台')">
                            上传图片
                            </button>
                        </div>
                    </div>
                    <br>

                </div>
                <br>




                <br>
                <div class="center" style="padding-left: 500px">
                    <a href="#" v-on:click="showUpload1">
                        <button type="button" class="btn btn-default" data-dismiss="modal" >上一步
                        </button></a>
                    <a href="#" v-on:click="showUpload3">
                        <button type="button" class="btn btn-primary">
                            下一步
                        </button></a>

                </div>
            </div>
        </div>

    </br>


    </div>`,
    data() {
        const that = this;
        bus.$on('upload', function (data) {
            that.pics.push({
                type: data.g_upload_column,
                src: data.g_object_name,
            });
            console.log(that.pics);
        });
      return {
          pics: [],
      }
    },
    methods:{
        showUpload1() {
            this.$emit('submit', {
                pics: this.pics,
            });
            this.$emit('show',1);
        },
        showUpload3() {
            this.$emit('submit', {
                pics: this.pics,
            });
            this.$emit('show',3);
        },
        clickif12() {
            if($("#if12").is(":checked")){
                $(".zl12").show();
            }else{
                $(".zl12").hide();
            }
        },
        changeColumn(s) {
          g_upload_column = s;
        },
    }
};
const upload3 = {
    template: `<div class="container-fluid">
        <div class="demo" width="80%">
            <ol class="progtrckr" data-progtrckr-steps="5">
                <li class="progtrckr-done">Step 1</li>
                <li class="progtrckr-done">Step 2</li>
                <li class="progtrckr-done">Step 3</li>
                <li class="progtrckr-todo">Step 4</li>
                <li class="progtrckr-todo">Step 5</li>
            </ol>
        </div>
        <br>
        <br>
        <div class="modal-body" style="padding-left: 50px">

            <div class="center" style="font-size: medium">

                <h3 class="modal-title" id="myModalLabel">
                    请选择您房屋中提供的设施并完善详情
                </h3>

                <br>

                <div style="padding-left: 50px">

                <div>
                    <label style="font-weight: normal"><input id="if1" type="checkbox" v-on:click="clickf1" v-model="bed">床</label>
                    
                    <div class="zl1" style=" display: none;padding-left: 46px;">
                    <textarea v-model="bedDescription" placeholder="请输入尺寸，材质等信息"></textarea>
                        <br>
                        <label>请上传该设施的实拍图片：</label>
                        <button class="btn" data-toggle="modal" data-target="#upload" v-on:click="changeColumn('bedPic')">
                            上传图片
                        </button>
                    </div>
                </div>
                <br>

                    <div>
                        <label style="font-weight: normal"><input id="if3" type="checkbox" v-on:click="clickf3" v-model="wardrobe">衣柜</label>
                        <div class="zl3" style=" display: none;padding-left: 46px;">
                            <textarea v-model="wardrobeDescription" placeholder="请输入尺寸，材质等信息"></textarea>
                        <br>
                        <label>请上传该设施的实拍图片：</label>
                        <button class="btn" data-toggle="modal" data-target="#upload" v-on:click="changeColumn('wardrobePic')">
                            上传图片
                        </button>
                        </div>
                    </div>
                    <br>

                <div>
                    <label style="font-weight: normal"><input id="if4" type="checkbox" v-on:click="clickf4" v-model="desk">书桌</label>
                    <div class="zl4" style=" display: none;padding-left: 46px;">
                        <textarea v-model="deskDescription" placeholder="请输入尺寸，材质等信息"></textarea>  
                        <br>
                        <label>请上传该设施的实拍图片：</label>
                        <button class="btn" data-toggle="modal" data-target="#upload" v-on:click="changeColumn('deskPic')">
                            上传图片
                        </button>
                    </div>
                </div>
                <br>

                <div>
                    <label style="font-weight: normal"><input id="if2" type="checkbox" v-on:click="clickf2" v-model="wifi">无线网络</label>
                    <div class="zl2" style=" display: none;padding-left: 46px;">
                        <textarea v-model="wifiDescription" placeholder="请输入网速，费用等信息"></textarea>
                    </div>
                </div>
                <br>

                <div>
                    <label style="font-weight: normal"><input id="if6" type="checkbox" v-on:click="clickf6" v-model="washer">洗衣机</label>
                    <div class="zl6" style=" display: none;padding-left: 46px;">
                        <textarea v-model="washerDescription" placeholder="请输入品牌，型号等信息"></textarea>
                        <br>
                        <label>请上传该设施的实拍图片：</label>
                        <button class="btn" data-toggle="modal" data-target="#upload" v-on:click="changeColumn('washerPic')">
                            上传图片
                        </button>
                    </div>
                </div>
                <br>

                <div>
                    <label style="font-weight: normal"><input id="if7" type="checkbox" v-on:click="clickf7" v-model="waterHeater">热水器</label>
                    <div class="zl7" style=" display: none;padding-left: 46px;">
                        <textarea v-model="waterHeaterDescription" placeholder="请输入品牌，型号等信息"></textarea>
                        <br>
                        <label>请上传该设施的实拍图片：</label>
                        <button class="btn" data-toggle="modal" data-target="#upload" v-on:click="changeColumn('waterHeaterPic')">
                            上传图片
                        </button>
                    </div>
                </div>
                <br>

                <div>
                    <label><input id="if8" type="checkbox" v-on:click="clickf8" v-model="airConditioning">空调</label>
                    <div class="zl8" style=" display: none;padding-left: 46px;">
                        <div class="zl9">
                            <textarea v-model="airConditioningDescription" placeholder="请输入品牌，型号等信息"></textarea>
                        <br>
                        <label>请上传该设施的实拍图片：</label>
                        <button class="btn" data-toggle="modal" data-target="#upload" v-on:click="changeColumn('airConditioningPic')">
                            上传图片
                        </button>
                        </div>
                    </div>
                </div>
                <br>
                <div>
                    <label style="font-weight: normal"><input id="if11" type="checkbox" v-on:click="clickf11" v-model="microwaveOven">微波炉</label>
                    <div class="zl11" style=" display: none;padding-left: 46px;">
                        <textarea v-model="microwaveOvenDescription" placeholder="请输入品牌，型号等信息"></textarea>
                        <br>
                        <label>请上传该设施的实拍图片：</label>
                        <button class="btn" data-toggle="modal" data-target="#upload" v-on:click="changeColumn('microwaveOvenPic')">
                            上传图片
                        </button>
                    </div>
                </div>
                </div>
                <br>




                <br>
                <div class="center" style="padding-left: 500px">
                    <a href="#" v-on:click="showUpload2()">
                        <button type="button" class="btn btn-default" data-dismiss="modal" >上一步
                        </button></a>
                    <a href="#" v-on:click="showUpload4()">
                        <button type="button" class="btn btn-primary">
                            下一步
                        </button></a>
                </br>

                </div>
                </div>
            </div>


    <br>


</div>`,
    data() {
        const that = this;
        bus.$on('upload', function (data) {
            that[data.g_upload_column] = data.g_object_name;
        });
      return {
          bed: false,
          bedDescription: '',
          bedPic: '',
          wardrobe: false,
          wardrobeDescription: '',
          wardrobePic: '',
          desk: false,
          deskDescription: '',
          deskPic: '',
          wifi: false,
          wifiDescription: '',
          wifiPic: '',
          washer: false,
          washerDescription: '',
          washerPic: '',
          waterHeater: false,
          waterHeaterDescription: '',
          waterHeaterPic: '',
          airConditioning: false,
          airConditioningDescription: '',
          airConditioningPic: '',
          microwaveOven: false,
          microwaveOvenDescription: '',
          microwaveOvenPic: '',
      }
    },
    methods: {
        changeColumn(s) {
            g_upload_column = s;
        },
        getDeviceStr() {
            let devices = [];
            let deviceDic = {
                bed: this.bed,
                wardrobe: this.wardrobe,
                desk: this.desk,
                wifi: this.wifi,
                washer: this.washer,
                waterHeater: this.waterHeater,
                airConditioning: this.airConditioning,
                microwaveOven: this.microwaveOven,
            };
            let deviceDescription = {
                bed: this.bedDescription,
                wardrobe: this.wardrobeDescription,
                desk: this.deskDescription,
                wifi: this.wifiDescription,
                washer: this.washerDescription,
                waterHeater: this.waterHeaterDescription,
                airConditioning: this.airConditioningDescription,
                microwaveOven: this.microwaveOvenDescription,
            };
            let devicePic = {
                bed: this.bedPic,
                wardrobe: this.wardrobePic,
                desk: this.deskPic,
                wifi: this.wifiPic,
                washer: this.washerPic,
                waterHeater: this.waterHeaterPic,
                airConditioning: this.airConditioningPic,
                microwaveOven: this.microwaveOvenPic,
            };
            for (const key in deviceDic) {
                if (deviceDic[key] === true) {
                    devices.push({
                        name: key,
                        description: deviceDescription[key],
                        pic: devicePic[key]
                    })
                }
            }
            this.$emit('submit', {
                devices: devices
            });
        },
        showUpload2() {
            this.$emit('show', 2);
            this.getDeviceStr();
        },
        showUpload4() {
            this.$emit('show', 4);
            this.getDeviceStr();
        },
        clickf1() {
            if($("#if1").is(":checked")){
                $(".zl1").show();
            }else{
                $(".zl1").hide();
            }
        },
        clickf2() {
            if($("#if2").is(":checked")){
                $(".zl2").show();
            }else{
                $(".zl2").hide();
            }
        },
        clickf3() {
            if($("#if3").is(":checked")){
                $(".zl3").show();
            }else{
                $(".zl3").hide();
            }
        },
        clickf4() {
            if($("#if4").is(":checked")){
                $(".zl4").show();
            }else{
                $(".zl4").hide();
            }
        },
        clickf5() {
            if($("#if5").is(":checked")){
                $(".zl5").show();
            }else{
                $(".zl5").hide();
            }
        },
        clickf6() {
            if($("#if6").is(":checked")){
                $(".zl6").show();
            }else{
                $(".zl6").hide();
            }
        },
        clickf7() {
            if($("#if7").is(":checked")){
                $(".zl7").show();
            }else{
                $(".zl7").hide();
            }
        },
        clickf8() {
            if($("#if8").is(":checked")){
                $(".zl8").show();
            }else{
                $(".zl8").hide();
            }
        },
        clickf9() {
            if($("#if9").is(":checked")){
                $(".zl9").show();
            }else{
                $(".zl9").hide();
            }
        },
        clickf10() {
            if($("#if10").is(":checked")){
                $(".zl10").show();
            }else{
                $(".zl10").hide();
            }
        },
        clickf11() {
            if($("#if11").is(":checked")){
                $(".zl11").show();
            }else{
                $(".zl11").hide();
            }
        }
    }
};
const upload4 = {
    template: `<div class="container-fluid">
        <div class="demo" width="80%">
            <ol class="progtrckr" data-progtrckr-steps="5">
                <li class="progtrckr-done">Step 1</li>
                <li class="progtrckr-done">Step 2</li>
                <li class="progtrckr-done">Step 3</li>
                <li class="progtrckr-done">Step 4</li>
                <li class="progtrckr-todo">Step 5</li>
            </ol>
        </div>
        <br>
        <br>
        <div class="modal-body">

            <div class="center" style="font-size: medium">
                <div class="modal-body" style="padding-left: 50px">

                    <div class="center" style="font-size: medium">
                        <h3 class="modal-title" id="myModalLabel">
                            请填写房屋的出租信息
                        </h3>
                        </br>
                        <div style="padding-left: 50px">

                            <div style="padding-left:111px;padding-top: 5px">
                                <label> 租金 &emsp;
                                    <input type="text" style="width:75px;font-weight: normal" v-model="price">元/每月
                                </label>
                            </div>

                            <div style="padding-left:111px;padding-top: 5px">
                                <label> 押金 &emsp;
                                    <input type="text" style="width:75px;font-weight: normal" v-model="deposit">元
                                </label>
                            </div>

                            <div style=" padding-left:48px;padding-top: 5px">
                                <label>
                                    最短出租时间 &emsp;
                                    <select style="font-weight: normal" v-model="period">
                                    <option selected="" value="0" disabled="">请选择</option>
                                    <option>1个月</option>
                                    <option>3个月</option>
                                    <option>6个月</option>
                                    <option>12个月</option>
                                    </select>
                                </label>
                            </div>


                            <div style="padding-left:84px;padding-top: 5px">
                                <label> 装修情况&emsp;
                                    <input type="text" style="width:350px;font-weight: normal" v-model="decoration">
                                </label>
                            </div>

                            <div style="padding-left:84px;padding-top: 5px">
                                <label> 保洁情况&emsp;
                                    <input type="text" style="width:350px;font-weight: normal" v-model="cleaning">
                                </label>
                            </div>


                            <div style="padding-left:21px;padding-top: 5px">
                                <label style="font-weight: normal">请上传房屋产权证&emsp;
                                   上传封面、内页
                                </label>
                                 <button class="btn" data-toggle="modal" data-target="#upload" v-on:click="changeColumn('license')">
                                    上传图片
                                </button>
                            </div>

                            <br>
                            <div style="padding-left: 440px">
                                <a href="#" v-on:click="showUpload3">
                                    <button type="button" class="btn btn-default" data-dismiss="modal" >上一步
                                    </button></a>
                                <a href="#" v-on:click="showUpload5">
                                    <button type="button" class="btn btn-primary">
                                        下一步
                                    </button></a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>`,
    data() {
        const that = this;
        bus.$on('upload', function (data) {
            that.pics.push({
                type: data.g_upload_column,
                src: data.g_object_name,
            });
            console.log(that.pics);
        });
      return {
          price: 0,
          deposit: 0,
          period: "0",
          decoration: '',
          cleaning: '',
          pics: [],
      }
    },
    methods: {
        changeColumn(s) {
            g_upload_column = s;
        },
        submit() {
          this.$emit('submit', {
              price: this.price,
              deposit: this.deposit,
              period: this.period,
              decoration: this.decoration,
              cleaning: this.cleaning,
              pics: this.pics,
          });
        },
        showUpload3() {
            this.$emit('show', 3);
            this.submit();
        },
        showUpload5() {
            this.$emit('show', 5);
            this.submit();
        },
    }
};
const upload5 = {
    template: `<div class="container-fluid">
        <div class="demo" width="80%">
            <ol class="progtrckr" data-progtrckr-steps="5">
                <li class="progtrckr-done">Step 1</li>
                <li class="progtrckr-done">Step 2</li>
                <li class="progtrckr-done">Step 3</li>
                <li class="progtrckr-done">Step 4</li>
                <li class="progtrckr-done">Step 5</li>
            </ol>
        </div>
        <br>
        <br>
        <div class="modal-body">

            <div class="center">
                <a href="#" v-on:click="showUpload4">
                     <button type="button" class="btn btn-default" data-dismiss="modal" >上一步
                </button></a>
            <button class="btn btn-primary" data-toggle="modal" data-target="#commit" v-on:click="submitAll">
                提交
            </button>
        </div>

        </div>
    </div>`,
    methods: {
        showUpload4() {
            this.$emit('show', 4);
        },
        submitAll() {
            this.$emit('complete');
        }
    }
};

var vm = new Vue({
    el: '#app',
    data: {
        currentView: 'upload1',
        part: {
            house: {},
            devices: [],
            pics: [],
        },
    },
    components: {
        upload1,
        upload2,
        upload3,
        upload4,
        upload5,
    },
    methods: {
        showUpload(i) {
            switch (i) {
                case 1:
                    this.currentView = 'upload1';
                    break;
                case 2:
                    this.currentView = 'upload2';
                    break;
                case 3:
                    this.currentView = 'upload3';
                    break;
                case 4:
                    this.currentView = 'upload4';
                    break;
                case 5:
                    this.currentView = 'upload5';
                    break;
            }
        },
        submitPart(o) {
            for (const key in o) {
                if (key !== 'devices' && key !== 'pics') {
                    this.part.house[key] = o[key];
                } else if (key === "devices"){
                    this.part.devices = o.devices;
                } else {
                    for (const i in o.pics) {
                        this.part.pics .push(o.pics[i]);
                    }
                }
            }
            console.log(this.part);
        },
        submitAll() {
            console.log(this.part.house);
            console.log(this.part.devices);
            $.ajax({
               url: '/house/upload',
               type: 'POST',
               data: JSON.stringify({
                   house: this.part.house,
                   devices: this.part.devices,
                   pics: this.part.pics,
               }),
                contentType: 'application/json',
                dataType: 'json',
                success() {
                   alert('发布成功');
                },
                error(e) {
                   console.error(e);
                },
            });

        }
    }
});